package com.chancingpack.controller;

import com.alibaba.fastjson.JSONObject;
import com.chancingpack.service.ImageService;
import org.apache.poi.util.SystemOutLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lenovo on 2017/7/20.
 */
@Controller
    @RequestMapping("/image")
public class ImageLoadController {

    @Autowired
    private ImageService imageService;

    @RequestMapping("/getUpLoad")
    public ModelAndView getList(){
        ModelAndView view=new ModelAndView("/image/upLoad");
        return view;
    }

    @RequestMapping(value="/upLoad",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String upLoad(HttpServletRequest request,String status){

      // String status = request.getParameter("0");
       // System.out.println(status);
        Map<String,Object> map = new HashMap<String, Object>();
        map = imageService.imageLoad(request,status);
       // System.out.println(map.get("flag")+"----"+map.get("msg"));
        return JSONObject.toJSONString(map);
    }
}
